package io.renren.modules.app.controller.user.user;

import io.renren.common.utils.PageUtils;
import io.renren.common.utils.R;
import io.renren.modules.app.entity.YcUserIntentionJobEntity;
import io.renren.modules.app.service.YcUserIntentionJobService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Arrays;
import java.util.Date;
import java.util.List;
import java.util.Map;



/**
 * 
 *
 * @author lym
 * @email 928185446qq.com
 * @date 2023-12-21 17:07:43
 */
@RestController
@RequestMapping("record/ycuserintentionjob")
public class YcUserIntentionJobController {
    @Autowired
    private YcUserIntentionJobService ycUserIntentionJobService;

    /**
     * 列表
     */
    @RequestMapping("/list")
    public R list(@RequestParam Map<String, Object> params){
        String id= (String) params.get("userId");
        System.out.println(id);
        // 获取求职意向信息
        List<YcUserIntentionJobEntity> UserIntentionJobList = ycUserIntentionJobService.getIntentionJob(Integer.parseInt(id));
        System.out.println(UserIntentionJobList);
        return R.ok().put("UserIntentionJobList", UserIntentionJobList);
    }


    /**
     * 信息
     */
    @RequestMapping("/info/{id}")
    @RequiresPermissions("record:ycuserintentionjob:info")
    public R info(@PathVariable("id") Integer id){
		YcUserIntentionJobEntity ycUserIntentionJob = ycUserIntentionJobService.getById(id);

        return R.ok().put("ycUserIntentionJob", ycUserIntentionJob);
    }

    /**
     * 保存
     */
    @RequestMapping("/save")

    public R save(@RequestBody YcUserIntentionJobEntity ycUserIntentionJob){
        //设置添加时间
        ycUserIntentionJob.setAddtime(new Date());
        ycUserIntentionJob.setDeletestatus(false);
        ycUserIntentionJobService.save(ycUserIntentionJob);
        return R.ok();
    }

    /**
     * 修改
     */
    @RequestMapping("/update")
    @RequiresPermissions("record:ycuserintentionjob:update")
    public R update(@RequestBody YcUserIntentionJobEntity ycUserIntentionJob){
		ycUserIntentionJobService.updateById(ycUserIntentionJob);

        return R.ok();
    }

    /**
     * 删除
     */
    @RequestMapping("/delete")
    public R delete(@RequestParam Map<String, Object> params){
		int jobId=Integer.parseInt(String.valueOf(params.get("id")));
        YcUserIntentionJobEntity ycUserIntentionJob =ycUserIntentionJobService.getById(jobId);
        ycUserIntentionJob.setDeletestatus(true);
        ycUserIntentionJobService.updateById(ycUserIntentionJob);
        return R.ok();
    }

}
